export default function(store) {
  const key = 'VUEX:STATE';
  // 刷新时会触发
  window.addEventListener('beforeunload', () => {
    sessionStorage.setItem(key, JSON.stringify(store.state));
  });
  try {
    const state = JSON.parse(sessionStorage.getItem(key));
    state && store.replaceState(state);
  } catch (error) {
    console.log(error);
  }
};
